package com.yuan.auth.controller;

import cn.common.utils.JwtUtils;
import com.alibaba.nacos.api.remote.response.Response;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/auth")
public class AuthController {
    @PostMapping("/login")
    public Response login(@RequestParam String phone, String password) {


        String token =  JwtUtils.generateToken(phone);
        System.out.println(token);
        return null;
    }

    @PostMapping("/validate")
    public Response validate(@RequestParam String tokens) {
        Boolean token =  JwtUtils.validateToken(tokens);
        System.out.println(token);
        return null;
    }
    @PostMapping("/getUser")
    public Response getUser(@RequestParam String tokenT) {
        String username =  JwtUtils.getUsernameFromToken(tokenT);
        System.out.println(username);
        return null;
    }
}
